package com.ly.shardingJdbc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ly.shardingJdbc.entity.TestLog;
import com.ly.shardingJdbc.entity.TestLogVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestLogMapper extends BaseMapper<TestLog> {

    @Select({"SELECT o.order_no, SUM(i.price * i.count) AS amount",
            "FROM test_log o JOIN test_log_item i ON o.order_no = i.order_no",
            "GROUP BY o.order_no"})
    List<TestLogVo> getOrderAmount();
}
